package com.huashi.dealer.commonEntity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.huashi.dealer.modular.business.user.param.RegionInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 订单收货地址记录表
 */
@Data
@TableName("yoshop_order_address")
@Schema(description = "订单收货地址记录表")
public class OrderAddress {
    @TableId(value = "order_address_id", type = IdType.AUTO)
    @Schema(description = "地址id")
    private Integer orderAddressId;

    @TableField("name")
    @Schema(description = "收货人姓名")
    private String name;

    @TableField("phone")
    @Schema(description = "联系电话")
    private String phone;

    @TableField("province_id")
    @Schema(description = "所在省份id")
    private Integer provinceId;

    @TableField("city_id")
    @Schema(description = "所在城市id")
    private Integer cityId;

    @TableField("region_id")
    @Schema(description = "所在区id")
    private Integer regionId;

    @TableField("detail")
    @Schema(description = "详细地址")
    private String detail;

    @TableField("order_id")
    @Schema(description = "订单id")
    private Integer orderId;

    @TableField("user_id")
    @Schema(description = "用户id")
    private Integer userId;

    @TableField("wxapp_id")
    @Schema(description = "小程序id")
    private Integer wxappId;

    @TableField("create_time")
    @Schema(description = "创建时间")
    private Long createTime;

    @TableField(exist = false)
    @Schema(description = "地区信息")
    private RegionInfo region;

    @Schema(description = "创建时间")
    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTimeFormat;


    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
        this.setCreateTimeFormat(LocalDateTime.ofEpochSecond(createTime, 0, java.time.ZoneOffset.ofHours(8)));
    }
}